<template>
	<view class="custom_me">
		<view class="summary-container">
			<u-avatar :src="photo" size="large"></u-avatar>
			<view class="summary">
				<view class="name">{{ name }}</view>
				<!--    <view class="level">
          <u-icon name="integral-fill" color="#FFA600" size="35" class="icon" />
          <text>${level}</text>
        </view> -->
			</view>
		</view>
		<u-cell-group>
			<u-cell-item icon="file-text-fill" title="订单" @click="this.toPage('../order_list/order_list')" />

			<!-- <u-cell-item v-if="false" icon="info-circle-fill" title="罚款" :value="fine" />
			<u-cell-item icon="coupon-fill" title="代金券" :value="voucher" @click="this.toPage('../voucher_list/voucher_list')" />
			<u-cell-item v-if="false" icon="server-fill" title="在线客服" />
			<u-cell-item v-if="false" icon="trash-fill" :icon-style="icon" title="清理缓存" @click="clearHandle" /> -->

			<!-- 用户指南 -->
			<u-cell-item icon="file-text-fill" :icon-style="icon" title="用户指南" @click="this.toPage('../../rule/user_guide/user_guide')" />

			<!-- 客服电话 -->
			<u-cell-item icon="phone" @click="callPhone" title="在线客服" :arrow="false" value="0724-8888008"></u-cell-item>

			<!-- 设置 -->
			<!-- <u-cell-item v-if="false" icon="setting-fill" title="设置" /> -->
		</u-cell-group>

		<!-- 退出登录按钮 -->
		<button class="btn" @tap="doLoginOut">退出登陆</button>
	</view>
</template>

<script>
export default {
	data() {
		return {
			photo: '',
			name: '',
			level: '',
			fine: '0.00元',
			voucher: '0张'
		};
	},
	methods: {
		initName() {
			this.name = uni.getStorageSync('userName');
			console.log(`获取本地的名称是:${this.name}`)
		},

		doLoginOut() {
			// console.log(`点击退出登录按钮了`)

			uni.showModal({
				title: '提示信息',
				content: '确认退出系统？',
				success: function(resp) {
					if (resp.confirm) {
						//清空本地存储状态
						uni.clearStorage();
						//跳转到登录界面
						uni.redirectTo({
							url: '../login/login'
						});
					}
				}
			});
		},
		
		//拨打电话
		callPhone(){
			uni.makePhoneCall({
				phoneNumber: '07248888008'
			});
		},
	},
	onLoad: function() {
		let that = this;
		that.ajax(that.url.searchUnUseVoucherCount, 'POST', {}, function(resp) {
			let result = resp.data.result;
			that.voucher = result + '张';
		});
		
		this.initName()
	}
};
</script>

<style lang="less">
@import url('mine.less');
</style>
